package com.telchina.model.controller;

import com.alibaba.fastjson2.JSON;
import com.telchina.common.core.text.Convert;
import com.telchina.model.entity.TModelManage;
import com.telchina.model.service.ITModelManageService;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.telchina.common.annotation.Log;
import com.telchina.common.core.controller.BaseController;
import com.telchina.common.core.domain.AjaxResult;
import com.telchina.common.enums.BusinessType;


/**
 * 设备模型(TModelManage)表控制层
 *
 * @author 郝振
 * @since 2023-06-17 17:01:42
 */
@RestController
@RequestMapping("/model/manage")
public class TModelManageController extends BaseController{
    /**
     * 服务对象
     */
   
	private final ITModelManageService tModelManageService;

    @Autowired
    public TModelManageController(ITModelManageService tModelManageService) {
        this.tModelManageService = tModelManageService;
    }
    /**
     * 分页查询
     *
     * @param tModelManage 筛选条件
     */
     @GetMapping("/list")
     public AjaxResult list(TModelManage tModelManage) {
        startPage();
        List<TModelManage> list = tModelManageService.selectTModelManageList(tModelManage);
        return AjaxResult.success(list);
     }
    /**
     * 获取详情
     *
     */
    @GetMapping("/getInfo")
    public AjaxResult getInfo(String id) {
        return AjaxResult.success(tModelManageService.getById(id));
    }
   
    /**
     * 新增设备模型
     *
     * @param tModelManage 实体
     */
	@Log(title = "设备模型管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody TModelManage tModelManage){
        return toAjax(tModelManageService.save(tModelManage));
    }
	
    /**
     * 编辑设备模型
     *
     * @param tModelManage 实体
     */
    @Log(title = "设备模型", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody TModelManage tModelManage){
        return toAjax(tModelManageService.updateById(tModelManage));
    }

    /**
     * 删除设备模型
     *
     * @param ids 主键
     */
	@Log(title = "设备模型", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(@RequestBody String ids){
        return success(tModelManageService.removeByIds(JSON.parseObject(ids, List.class)));
    }
	

}

